import routes from './router/routes'
import packageConfig from '../package.json'
export default function (Vue) {
  const files = require.context('./components', true, /^(?!.*(?:internals|docShield$)).*\.vue$/)
  files.keys().forEach((element, index) => {
    const url = 'components/' + element.substring(2)
    const urlArr = element.split('/')
    const urlArrLen = urlArr[urlArr.length - 1]
    const name = urlArrLen.substring(0, urlArrLen.length - 4)
    Vue.component(`${packageConfig.name}-${name.toLowerCase()}`, resolve => {
      require([`@/${url}`], resolve)
    })
  })
  Vue.config.productionTip = false
  this.$router.addRoutes(routes)
}
